<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
</head>

<script type="text/javascript">
    function modifyEmail() {
        location.href = jsctx + "/member/index";
    };
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <div class="titleBorder "><span class="titlePiece"></span><span class="orderInfoTitleFont"
                                                                        style="font-size: 250%;">控制台</span></div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">今日新增会员数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="newAddCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">会员数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="allCount"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">未读客服消息：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="unreadMsgCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">企业账号申请总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="applyCount"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">在线桩：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="loginPileCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">枪使用：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="useGuncount"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">充电桩总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="pileCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">充电枪总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="guncount"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">直流桩总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="directCurrentPileCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">交流桩总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="exchangePileCount"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">交直流一体总数：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="directCurrentAndExchangePileCount"></span></span>
            </div>
            <label class="col-sm-2 col-form-label text-right">全部充电桩在线率：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="pileOnlineRate"></span></span>
                <button class="btn btn-info" onclick="showModel()">查看详情</button>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right">总功率：</label>
            <div class="col-sm-3">
                <span class="eva-p1"><span class="totalPowerByStation"></span></span>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-right"></label>
            <div class="col-sm-3">
                <button class="btn btn-info" onclick="selectStatistics()">刷新</button>
            </div>
        </div>

    </div>
</div>


<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true"></span></button>
                <h4 class="modal-title" id="exampleModalLabel" data-dismiss="modal" aria-label="Close">
                    关闭</h4>
            </div>

            <div class="modal-body">
                <form id="contentForm" class="layui-form">
                    <div class="form-group row">
                        <label class="col-sm-5 col-form-label text-right">在线率过低短信通知</label>
                        <div class="col-sm-8">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-4">是否短信通知:</label>
                        <div class="col-sm-8">
                            <input type="radio" class="form-control" name="openPileOnlineWarn"
                                   lay-filter="openPileOnlineWarn"
                                   title="是" value="0">
                            <input type="radio" class="form-control" name="openPileOnlineWarn"
                                   lay-filter="openPileOnlineWarn"
                                   title="否" value="1">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-4">桩在线率警示值:</label>
                        <div class="col-sm-3">
                            <input class="form-control" id="pileOnlineWarnValue" name="pileOnlineWarnValue">
                        </div>
                        <div class="col-sm-3">
                            %
                        </div>
                    </div>
                    <span class="help-block m-b-none"><font color="#ff8c00"
                                                            size="1">在线率低于该值时自动给对应手机号发送低警示信息</font></span>

                    <div class="form-group row">
                        <label class="col-sm-4 col-form-label text-right">接收短信手机号:</label>
                        <div class="col-sm-6">
                            <textarea class="form-control" id="pileOnlineWarnMobiles" style="height: 12%;width: 100%"
                                      name="pileOnlineWarnMobiles" onmouseout="mouseOut()"></textarea>
                        </div>
                    </div>
                    <span class="help-block m-b-none"><font color="#ff8c00"
                                                            size="1">多个手机号用英文逗号分开,最大为10个手机号</font></span>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-success" id="giftMember">保存</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function mouseOut() {
        var phone = $("#pileOnlineWarnMobiles").val();
        phone = phone.replace(/，/ig, ',');
        var arr = phone.split(",");
        $("#pileOnlineWarnMobiles").val(arr)
    }

    layui.use(['form', 'jquery', 'tree', 'laydate', 'util'], function () {
        var form = layui.form;
        var $ = layui.jquery;

    })


    function selectStatistics() {
        $.ajax({
            cache: true,
            type: "GET",
            url: jsctx + "/statistics/selectStatistics",
            data: {},
            // async: false,
            error: function (request) {
                console.log("Connection error");
            },
            success: function (data) {
                if (data.status == 200) {
                    $(".newAddCount").html(data.data.newAddCount)
                    $(".allCount").html(data.data.allCount)
                    $(".unreadMsgCount").html(data.data.unreadMsgCount)
                    $(".applyCount").html(data.data.applyCount)
                    $(".loginPileCount").html(data.data.loginPileCount)
                    $(".useGuncount").html(data.data.useGuncount)
                    $(".pileCount").html(data.data.pileCount)
                    $(".guncount").html(data.data.guncount)
                    $(".directCurrentPileCount").html(data.data.directCurrentPileCount)
                    $(".exchangePileCount").html(data.data.exchangePileCount)
                    $(".directCurrentAndExchangePileCount").html(data.data.directCurrentAndExchangePileCount)
                    $(".pileOnlineRate").html(data.data.pileOnlineRateVo)
                    $(".totalPowerByStation").html(data.data.totalPowerByStation)

                    $("#pileOnlineWarnValue").val(data.data.pileOnlineWarnValue)
                    $("#pileOnlineWarnMobiles").html(data.data.pileOnlineWarnMobiles)

                    if (data.data.openPileOnlineWarn == '1') {
                        $("input[name='openPileOnlineWarn']")[1].checked = true;
                    } else if (data.data.openPileOnlineWarn == '0') {
                        $("input[name='openPileOnlineWarn']")[0].checked = true;
                    }
                    layui.form.render();
                } else {
                    console.log(data.message);
                }

            }
        });
    }

    selectStatistics();


    /*  模态框  */
    function showModel(sort, ulId) {
        //  $("#recipient-name").val(sort)
        //  $("#ulId").val(ulId)
        $('#exampleModal').modal('show')

        $("#giftMember").unbind("click").bind("click", function () {

            var formData = new FormData();
            formData.append("openPileOnlineWarn", $("input[type=radio]:checked").val());
            formData.append("pileOnlineWarnValue", $("#pileOnlineWarnValue").val());
            formData.append("pileOnlineWarnMobiles", $("#pileOnlineWarnMobiles").val());
            $.ajax({
                url: jsctx + "/statistics/savePileWarn",
                type: "post",
                data: formData,
                dataType: "json",
                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data.status == 200) {
                        selectStatistics();
                        parent.layer.msg("操作成功");
                        // $('#exampleModal').on('hidden.bs.modal', function () {
                        //     document.getElementById("contentForm").reset();
                        // })
                        $('#exampleModal').modal('hide')
                        reLoad();
                    } else {
                        console.log(data.message);
                        // $('#exampleModal').on('hidden.bs.modal', function () {
                        //     document.getElementById("contentForm").reset();
                        // })
                        //  $('#exampleModal').modal('hide')
                    }

                }
            })
        })


        // $("#giftMember").click(function () {
        //
        //
        // })
    }
</script>
</body>
</html>